<?php

/**
 * Description of guestLoginAction
\* www.teuker.nl - mail@teuker.nl
 * 
 * @author francisc
 */

class guestLoginAction extends sfAction {

    public function execute($request) {
        $restaurant_name = $request->getParameter('restaurant_name');
        $restaurant = SqlEngine::getRestaurants(array('name_like' => $restaurant_name));

        if (1 != count($restaurant)) {
            $this->getUser()->setFlash('error', 1);
            return sfView::SUCCESS;
        }
        
        $settings = SqlEngine::getSettings(array('restaurant_id' => $restaurant[0]['restaurant_id']));
        
        $this->getUser()->setAttribute('user_type', 'guest');
        Util::set_session_info($restaurant[0], $settings, $this->getUser());

        $this->redirect('@reservation_guest');
    }
}
